﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WorldOfSuperpowers_COMMON.DataModel;

public class TransformNetGetter : MonoBehaviour
{
    public uint RoleID;
    public Transform RoleTran;
    public AnimController AnimC;

    /// <summary>
    /// 初始化函数
    /// </summary>
    /// <param name="_roleTran">角色transform组件</param>
    /// <param name="_animC">角色动画控制器</param>
    /// <param name="_roleID">角色id</param>
    public void Init(Transform _roleTran,AnimController _animC,uint _roleID)
    {
        RoleID = _roleID; 
        RoleTran = _roleTran;
        AnimC = _animC;
        //todo 将GetPosModel挂在到客户端同步委托中，以id为角色标志
    }

    /// <summary>
    /// 同步函数
    /// </summary>
    /// <param name="model">同步信息</param>
    public void GetPosModel(UpdateMoveModel model)
    {
        Vector3 pos = new Vector3(NumTools.GetInstance().GetFloatFromInt(model.posArr[0]), NumTools.GetInstance().GetFloatFromInt(model.posArr[1]), NumTools.GetInstance().GetFloatFromInt(model.posArr[2]));
        Vector3 dir = new Vector3(NumTools.GetInstance().GetFloatFromInt(model.dirArr[0]), NumTools.GetInstance().GetFloatFromInt(model.dirArr[1]), NumTools.GetInstance().GetFloatFromInt(model.dirArr[2]));
        Vector2 moveAxis = new Vector2(NumTools.GetInstance().GetFloatFromInt(model.moveAnimAxis[0]), NumTools.GetInstance().GetFloatFromInt(model.moveAnimAxis[1]));
        //执行
        RoleTran.position = pos;
        RoleTran.eulerAngles = dir;
        AnimC.TouchOnMove(moveAxis);
    }

}
